Skip to content

fix(core): hold a coordinator's state until its claim is accepted, and evict by time offline - #601

Merged
Mearman merged 2 commits into
mainfrom
fix/agent-intake-follow-ups
Nov 15, 2026
Merged

Mearman merged 2 commits into
mainfrom
fix/agent-intake-follow-ups

Conversation

@Mearman

@Mearman Mearman commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Merging publishes a patch release of agent-comms.

Follow-ups to the intake rules for an agent's record. It does not authenticate the coordinator, and it does not check rooms, messages or delivery events.

  • A coordinator's snapshot, record update or departure can be read before the claim that names it is accepted. What is refused only for want of that authority is held per sender and applied when a claim naming the sender is accepted. A held entry expires after one claim wait, is dropped when a claim naming another peer is accepted, and a held departure is applied only if the agent's record has not changed since it was held. Records that are malformed are not held. Up to 16 senders can be held at once, so that many trusted peers can take every place and a legitimate successor's state is then not held.
  • At the bound on agents, the record that has been offline longest is evicted, in the order this store saw records go offline (kept in the store, never sent), found without scanning every record. The order follows a record's status through the store's own map, including a status gossiped by presence, and eviction checks the status again before taking a record.
  • New agents are counted per connection, 512 for each, with the bound on all agents together as the only bound across connections: one machine or host that presents many device keys has a bound for each key. A connection at its bound replaces its own offline record and is otherwise refused. What a connection introduced is forgotten when the store removes or evicts the record.
  • Once a store's own agent is offline, a snapshot's record of it is ignored instead of applied whole.
  • forget no longer touches the identity cache, whose keys are not agent ids.

Tests cover each rule, including the order in which a snapshot and a claim are read and a peer entry that is rewritten, and each was run against a mutation that its test fails.

…d evict by time offline

A coordinator's snapshot or announcement can be read before the claim that names it is
accepted, so what was refused only for want of that authority is held per sender and applied
when its claim is accepted. A held record expires after one claim wait, is dropped when a claim
naming another peer is accepted, and a held departure is applied only if the agent's record is
as it was when it was held.

At the bound on agents, the record offline longest is evicted, in the order the store saw them
go offline and found without scanning every record. New agents are counted per origin (the host
a peer was reached at, or this machine) instead of per device key, and an origin at its bound
replaces its own offline record. The identity cache entry that forget cleared was keyed
differently and is no longer touched.

Once a store's own agent is offline, a snapshot's record of it is ignored instead of applied
whole, and a dialled coordinator's records are covered by a test.
…nts per connection

A record whose status is changed by gossiped presence is stored again, so the order in which
records went offline follows the real status: an agent brought back is no longer the first to be
evicted, and one taken offline becomes evictable. Eviction also checks the record's status
before taking it.

The bound on new agents is per connection, taken from the sender and not from the host a peer
entry names, which any trusted peer can rewrite. What a connection introduced is forgotten
when the store removes or evicts the record, and not only when the connection is checked again.
@Mearman
Mearman force-pushed the fix/agent-intake-follow-ups branch from beb40ee to fc4d205 Compare November 15, 2026 17:10
@Mearman
Mearman marked this pull request as ready for review November 15, 2026 17:21
@Mearman
Mearman merged commit 94a4995 into main Nov 15, 2026
11 checks passed
@Mearman
Mearman deleted the fix/agent-intake-follow-ups branch November 15, 2026 17:22
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 10.0.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant